package com.hzhr.iot.cqgas.ds.controller;

import com.hzhr.iot.cqgas.ds.dao.device.example.DevProdFactoryDao;
import com.hzhr.iot.cqgas.ds.entity.device.DevProdFactoryEntity;
import com.hzhr.iot.cqgas.ds.entity.device.DevProdFactoryExample;
import com.hzhr.iot.cqgas.ds.service.ProdFactoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProdFactoryController {
    @Autowired
    ProdFactoryService prodFactoryService;
    @Autowired
    DevProdFactoryDao devProdFactoryDao;

    @RequestMapping(value = "/syncProdFactory")
    public void syncProdFactory() {
        DevProdFactoryEntity devProdFactoryEntity = new DevProdFactoryEntity();
        devProdFactoryEntity.setState("3");
        DevProdFactoryExample devProdFactoryExample = new DevProdFactoryExample();
        devProdFactoryExample.createCriteria().andOutIdIsNotNull();
        devProdFactoryDao.updateByExampleSelective(devProdFactoryEntity, devProdFactoryExample);

        prodFactoryService.syncProdFactory();

        devProdFactoryExample = new DevProdFactoryExample();
        devProdFactoryExample.createCriteria().andStateEqualTo("3");
        devProdFactoryDao.deleteByExample(devProdFactoryExample);
    }
}
